package com.cecsmsserve.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cecsmsserve.entity.HealthReminder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface HealthReminderMapper extends BaseMapper<HealthReminder> {
    
    @Select("SELECT hr.*, hrt.name as type_name, u.username as user_name " +
            "FROM health_reminder hr " +
            "LEFT JOIN health_record_type hrt ON hr.type_id = hrt.id " +
            "LEFT JOIN user u ON hr.user_id = u.id " +
            "WHERE hr.user_id = #{userId} " +
            "ORDER BY hr.is_active DESC, hr.reminder_time ASC")
    Page<HealthReminder> getRemindersByUserIdWithPage(
            Page<HealthReminder> page,
            @Param("userId") Integer userId);
    
} 